<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Gerenciamento Escola - Disciplina</title>
<script type="text/javascript" src="js/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="js/validacao.js"/></script>
<script type="text/javascript" src="js/jquery.maskedinput-1.3.js"></script>
<link rel="stylesheet" type="text/css" href="css/style.css" />

</head>
<body>
<div class="divLogout"><a href="logoutServlet"><c:out value="Logout(${sessionUser.login})"></c:out></a></div>


<div class="tablegrid">

	<table class="tableListUser" >
			<tr height="28px">
				<td class="celListCenter"> <a href="listarProfessores">Professores</a></td>
				<td class="celListCenter"> <a href="listarAlunos">Alunos</a></td>
				<td class="celListCenter"> <a href="listarDisciplinas">Disciplinas</a></td>
				<td class="celListCenter"> <a href="listarUsuarios">Usuários</a></td>
			</tr>
			<tr height="28px">
				<td colspan="4" align="center">Gerenciamento de Disciplinas</td>
			</tr>
			<tr>
            	<td align="center"  colspan="2">
                    <a href="listarDisciplinas"><img class="icone" src="img/icon/disc_search.png"/></a>
                </td>
                <td align="center"  colspan="2" >
                    <a href="disciplina"><img class="icone" src="img/icon/disc_add.png"/></a>
                </td>
            </tr>
            <tr>
            	<td align="center"  colspan="2">
                    <a href="listarDisciplinas">Listar Disciplinas</a>
                </td>
                <td align="center"  colspan="2" >
                    <a href="disciplina">Adicionar Disciplina</a>
                </td>
            </tr>
		</table>			
		<div class="formHeader">Disciplina</div>
	
	
	<c:if test="${not empty param.msg}">
		<div class="erroMsg">
		
				<c:choose>
					<c:when test="${param.msg eq 'disc_name_empty'}">
						Nome é informação obrigatória.				
					</c:when>
					<c:when test="${param.msg eq 'disc_name_invalid_length'}">
						Nome deve conter de 8 até 80 caracteres.				
					</c:when>
					<c:when test="${param.msg eq 'disc_cont_empty'}">
						Conteudo inválido.
									
					</c:when>
					<c:when test="${param.msg eq 'disc_cont_invalid_length'}">
						Conteudo deve conter de 8  até 140 caracteres.				
					</c:when>
					<c:when test="${param.msg eq 'disc_carga_horaria'}">
						Carga horária do professor excedida.
					</c:when>
				</c:choose>
			</div>
	</c:if>


	<form  onsubmit="return verificaDisciplina()" action="disciplina" method="post">
		<input type="hidden" name="acao" value="salvar" />
		<input type="hidden" name="id" value="${disciplina.id}" />
		<table class="tableform" >
						
		
			<tr>
				<td class="nomeCampo">Nome:</td>
				<td><input type="text" id="nome" name="nome" maxlength="80" size="40" value="${disciplina.nome}"/></td>
			</tr>
			<tr>
				<td class="nomeCampo">Carga Horaria:</td>
				<td>
					<input type="text" id="carga_horaria" name="carga_horaria" value="${disciplina.cargaHoraria}"/>
				</td>
			</tr>
			<tr>
				<td class="nomeCampo">Professor:</td>
				<td>
				<select name="idProfessor" id="idProfessor"  >
					<option value="0"><c:out value="Não definido"/></option>
					<c:forEach items="${professores}" var="professor" >
						<option value="${professor.id}" ${professor.id eq disciplina.professor.id ? 'selected' : '' }>
							<c:out value="${professor.nome} - ${professor.id}"/>
						</option>
					</c:forEach>	
				</select>
				</td>
			</tr>
			<tr>
				<td class="nomeCampo">Counteudo:</td>
				<td><textarea cols="40" rows="4" id="conteudo" name="conteudo" ><c:out value="${disciplina.conteudo}"/></textarea>
				</td>
			</tr>
			<tr>
				<td colspan="2" align="center"><input type="submit" value="Salvar" value="${disciplina}"/></td>
			</tr>
		</table>
	</form>
	
	</div>





</body>
</html>